package com.service.order.controller;

import com.model.order.pojo.entity.Order;
import com.service.order.properties.OrderProperties;
import com.service.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
// @RefreshScope // 刷新配置
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    // 方法1： @Value 注解获取配置 @RefreshScope 刷新配置
    // 方法2： @ConfigurationProperties 注解获取配置
    // @Value("${aliyun.secretId}")
    // String secretID;
    @Resource
    OrderProperties orderProperties;
    @GetMapping("/getSecretID")
    public String getSecretID() {
        return "secretId: " + orderProperties.getSecretID();
    }

    @PostMapping("/getOrderById")
    public Order getOrderById(@RequestParam("orderId") Long orderId, @RequestParam("productId") Long productId) {
        return orderService.getOrderById(orderId, productId);
    }

}
